﻿$(function () {
    $('input.clear-default').click(function () {
        if ($(this).val() == this.defaultValue)
            $(this).val('');
    });
    $('form').validationEngine({ scroll: false, promptPosition: "centerLeft" });
    $('a[href*=WebForm_DoPostBackWithOptions]').click(function (e) {
        $('input.clear-default').each(function () {
            if ($(this).val() == this.defaultValue)
                $(this).val('');
        });
        if (!$('form').validationEngine('validate')) {
            e.preventDefault();
            e.stopPropagation();
        }
    })
});

function regexValidation(field, rules, i, options) {
    var valid = false;
    var r = new RegExp(field.attr('data-regex'));
    valid = r.test(field.val());
    if (!valid)
        return field.attr('data-errormessage-funcCall[regexValidation]');
}